package cn.com.connext.scrm.repository.master;


import cn.com.connext.scrm.domain.master.ActivityModuleConfig;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface ActivityModuleConfigRepository extends JpaRepository<ActivityModuleConfig, Long>, JpaSpecificationExecutor {
    @Query(value = "select * from activity_module_config order by config_order desc limit 1", nativeQuery = true)
    ActivityModuleConfig findOrderLimitOne();

    ActivityModuleConfig findByComponentName(String componentName);

    @Query(value = "select * from activity_module_config  where component_name like CONCAT('%',:componentName,'%')", nativeQuery = true)
    List<ActivityModuleConfig> findByComponentNameLike(@Param("componentName") String componentName);

    @Query(value = "select * from activity_module_config where component_name = ?1 and type = ?2",nativeQuery = true)
    ActivityModuleConfig findByComponentNameAndType(String componentName,Integer type);
}
